<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="yingxiao_vpp_indexad";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
global $OTHERLINK;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
if($actions=="up")
{
	$db->excu("UPDATE mx_vpp_indexad SET ifhide='$ifhide' WHERE id='$id'");
	jump2("修改成功","$FROMURL",0);
	exit();
}
elseif($actions=="yz")
{
	$db->excu("UPDATE mx_vpp_indexad SET yz='$ifyz' WHERE id='$id'");
	jump2("修改成功","$FROMURL",0);
	exit();
}
elseif($actions=="del"){
//删除图片
	if(!$iddb&&!$id){
		$fun->popmassage("请选择一篇文章","","popback");
		exit();
	}
	elseif(is_array($iddb))
	{
		foreach($iddb AS $key=>$value){
			$db->excu("DELETE FROM mx_vpp_indexad WHERE id='$key' ");
		}
	}elseif($id){
		$db->excu("DELETE FROM mx_vpp_indexad WHERE id='$id' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
}
elseif($actions=="list")
{
//更新选中信息排列顺序
	foreach( $listdb AS $key=>$value){
		$db->excu("UPDATE mx_vpp_indexad SET list='$value' WHERE id='$key'");
	}
	jump2("修改成功","$FROMURL",1);
	exit();
}
elseif($actions=="saveadd")
{
  if($postdb[name]=="" || empty($postdb[name])){
		$fun->popmassage("请填写网站名称","","popback");
		exit();
  }
  if($postdb[url]=="" || empty($postdb[url])){
		$fun->popmassage("请填写网站地址","","popback");
		exit();
  }
  $fid=intval($fid);
  $postdb[ifhide]=intval($postdb[ifhide]);
  $postdb[yz]=intval($postdb[yz]);
  if ($orderid==""){$orderid=666;}
	$db->excu("INSERT INTO mx_vpp_indexad (fid,name , url , logo , descrip , list,ifhide,yz,adddate,addid) VALUES ('$fid','$postdb[name]','$postdb[url]','$postdb[logo]','$postdb[descrip]','$orderid','$postdb[ifhide]','$postdb[yz]','".date("Y-m-d H:i:s")."','".$_SESSION['mxadmin']['username']."')");
	jump2("添加成功","yx_vpp_indexad.php");
	exit();
}
elseif ($actions=="savemodi"){
    if($id=="" || empty($id)){
		$fun->popmassage("请选择要修改的链接","","popback");
		exit();
  }
  if($postdb[name]=="" || empty($postdb[name])){
		$fun->popmassage("请填写网站名称","","popback");
		exit();
  }
  if($postdb[url]=="" || empty($postdb[url])){
		$fun->popmassage("请填写网站地址","","popback");
		exit();
  }
  $fid=intval($fid);
  $postdb[ifhide]=intval($postdb[ifhide]);
  $postdb[yz]=intval($postdb[yz]);
  if ($orderid==""){$orderid=666;}
  $db->excu("UPDATE mx_vpp_indexad SET fid='$fid',name='$postdb[name]',url='$postdb[url]',logo='$postdb[logo]',descrip='$postdb[descrip]',list='$orderid',ifhide='$postdb[ifhide]',yz='$postdb[yz]',modidate='".date("Y-m-d H:i:s")."',modiid='".$_SESSION['mxadmin']['username']."' WHERE id='$id'");

	if (trim($gotourl)==""){
	$gotourl=$FROMURL;
	}else{$gotourl=url_code($gotourl);}
	jump2("修改成功","$gotourl",1);
	exit();
}
?>
<?php require("../mx_head.php");?>
<div class="right">
<div class="gk">
			<div class="ti2 fl">幻灯片管理</div>
			<ul class="fr">
				<li><span class="c1"><?php $znum=$db->listcount("mx_vpp_indexad","");echo $znum;?></span><span>总条数</span></li>
				<li class="line"></li>
				<li><span class="c2"><?php $znum=$db->listcount("mx_vpp_indexad"," and yz='1'");echo $znum;?></span><span>已审核</span></li>
				<li class="line"></li>
				<li><span class="c3"><?php $znum=$db->listcount("mx_vpp_indexad"," and yz='0'");echo $znum;?></span><span>未审核</span></li>
			</ul>
			<div class="clear"></div>
</div>
<div class="height15"></div>
<?php if ($actions=="add"){?>
<div class="xm2">
<h1 class="fl">添加幻灯片</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="yx_vpp_indexad.php?actions=saveadd" onSubmit="return  check();">
    <tr class="list" style="display:none;"> 
      <td width='20%'>所属位置：</td>
      <td colspan="2"><select name="fid">
	  <option value="">选择所属位置</option>
	  <?php
	  foreach($OTHERLINK as $key=>$value){
	      echo '<option value="'.$key.'">'.$value.'</option>';
	  }
	  ?>
	  </select></td>
    </tr>
    <tr class="list"> 
      <td>链接名称：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[name]' value='<?php echo $rsdb[name]?>' size="60">      </td>
    </tr>
    <tr class="list"> 
      <td>网址：</td>
      <td colspan="2"><input class=mmcinb type='text' name='postdb[url]2' value='<?php echo $rsdb[url]?>' size='50'></td>
    </tr>
    <tr class="list"> 
      <td>图片：</td>
      <td colspan="2"><table cellpadding="0" cellspacing="0" border="0"><tr><td><input class=mmcinb type='text' name='postdb[logo]' value='<?php echo $rsdb[logo]?>' id="pic" size="40"></td><td>&nbsp;<a href="javascript:show_uplode('upfile','indexad','pic')"><font color="#FF0000">点击上传图片</font></a></td></tr></table></td>
    </tr>
    <tr class="list"> 
      <td>描述介绍(可不填)：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[descrip]' value='<?php echo $rsdb[descrip]?>' size='60'>      </td>
    </tr>
    <tr class="list"> 
      <td>链接排序：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='orderid' id="orderid" value='666' size='20'>      </td>
    </tr>
    <tr class="list"> 
      <td>验证与否</td>
      <td height="30" colspan="2"> 
        <input type="radio" name="postdb[yz]" value="1" checked="checked" class="input_check">
        已验证 
        <input type="radio" name="postdb[yz]" value="0" class="input_check">
        未验证</td>
    </tr>
    <tr class="list"> 
      <td width='19%'></td>
      <td colspan="2"> 
        <input class="button" type='submit' name='Submit' value='提交数据'>      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}
elseif ($actions=="modi"){
//修改链接
  $query="SELECT * FROM mx_vpp_indexad where id='$id' limit 1";
  $result=$db->excu($query);
  if ($db->num_rows($result)<=0){
	$fun->popmassage("请选择要修改的链接","","popback");
	exit();
  }
  $rsdb=$db->fetch_array($result);
	$rsdb[ifhide]=intval($rsdb[ifhide]);
	$ifhide[$rsdb[ifhide]]=" checked ";
	$rsdb[yz]=intval($rsdb[yz]);
	$yz[$rsdb[yz]]=" checked ";
    $fidstr[$rsdb["fid"]]=" selected";
	if ($gotourl==""){$gotourl=url_encode($_SERVER['HTTP_REFERER']);}
?>
<div class="xm2">
<h1 class="fl">修改幻灯片</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="yx_vpp_indexad.php" onSubmit="return  check();">
    <tr class="list" style="display:none;"> 
      <td width='20%'>所属位置：</td>
      <td colspan="2"><select name="fid">
	  <option value="">选择所属位置</option>
	  <?php
	  foreach($OTHERLINK as $key=>$value){
	      echo '<option value="'.$key.'" '.$fidstr["$key"].'>'.$value.'</option>';
	  }
	  ?>
	  </select></td>
    </tr>
    <tr class="list"> 
      <td>链接名称：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[name]' value='<?php echo $rsdb[name]?>' size="60">      </td>
    </tr>
    <tr class="list"> 
      <td>网址：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[url]' value='<?php echo $rsdb[url]?>' size='50'>      </td>
    </tr>
    <tr class="list"> 
      <td>图片：</td>
      <td colspan="2"> 
      <table cellpadding="0" cellspacing="0" border="0"><tr><td><input class=mmcinb type='text' name='postdb[logo]' value='<?php echo $rsdb[logo]?>' id="pic" size="40"></td><td>&nbsp;<a href="javascript:show_uplode('upfile','indexad','pic')"><font color="#FF0000">点击上传图片</font></a></td></tr></table></td>
    </tr>
    <tr class="list"> 
      <td>描述介绍(可不填)：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='postdb[descrip]' value='<?php echo $rsdb[descrip]?>' size='60'>      </td>
    </tr>
    <tr class="list"> 
      <td>链接排序：</td>
      <td colspan="2"> 
        <input class=mmcinb type='text' name='orderid' id="orderid" value='<?php echo $rsdb["list"]?>' size='20'>      </td>
    </tr>
    <tr class="list"> 
      <td>验证与否</td>
      <td height="30" colspan="2"> 
        <input type="radio" name="postdb[yz]" value="1" class="input_check" <?php echo $yz[1]?>>
        已验证 
        <input type="radio" name="postdb[yz]" value="0" class="input_check" <?php echo $yz[0]?>>
        未验证</td>
    </tr>
    <tr class="list"> 
      <td width='19%'> 
        <div align='right'></div>      </td>
      <td colspan="2"> 
        <input class="button" type='submit' name='Submit' value='提交数据'>
		<input type="hidden" name="id" value="<?php echo $rsdb[id] ?>">
		<input type="hidden" name="gotourl" value="<?php echo $gotourl?>">
		<input type="hidden" name="actions" value="savemodi">      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}

else{
  $str="";
  $s="";
  if(empty($pageindex)){
      $pageindex=1;
  }
  $pagesize=15;

  if ($yz!=""){
  	$yz=intval($yz);
	$str.=" and yz='$yz' ";
	$s.="yz=$yz&";
  }
  $table=" mx_vpp_indexad ";
  $order=" order by list asc, id desc";
  $column=" * ";
  $biaoid="id";
  $c=$db->listcount($table,$str);
  
  $list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);
?>
<div class="xm2">
<h1 class="fl">幻灯片管理</h1>
</div>
<div class="xm2_b" style="border-bottom:0px;">
<div class="t">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="an1"><a href="yx_vpp_indexad.php">所有信息</a></div>
	<div class="an2"><a href="yx_vpp_indexad.php?actions=add">添加幻灯片</a></div>
	<div class="an2"><a href="yx_vpp_indexad.php?yz=1">已审核</a></div>
	<div class="an2"><a href="yx_vpp_indexad.php?yz=0">未审核</a></div>
	</td>
	</tr>
	</table>
</div>
</div>
<div class="xm2_b">
<div class="height10"></div>

<table width='100%' cellspacing='1' cellpadding='3' class="table_southidc">
<form name="form1" method="post" action="yx_vpp_indexad.php">
    <tr class="head"> 
      <th width="5%" align="center">ID </th>
      <th width="17%" align="center">名称</th>
<!--
      <th width="18%" align="center">所属位置</th>
      <th width="9%" align="center">首页显示</th>
-->
      <th width="8%" align="center">排序</th>
      <th width="12%" align="center">审核与否</th>
      <th width="13%" align="center">操作</th>
    </tr>
<?php
  if (!is_array($list)){
  echo "<tr class=\"list\"><td colspan=5><center>暂无信息</center></td></tr>";
  }
  else{
  for($i=0;$i<count($list);$i++){
		$list[$i][yz]=$list[$i][yz]?"<A HREF='?actions=yz&ifyz=0&id=".$list[$i][id]."' style='color:red;' title='取消审核'>已审核</A>":"<A HREF='?actions=yz&ifyz=1&id=".$list[$i][id]."' style='color:blue;' title='审核通过'>未审核</A>";
?>
    <tr class="list"> 
      <td width='5%' align="center"><input type="checkbox" name="iddb[<?php echo $list[$i][id]?>]" value="<?php echo $list[$i][id]?>" class="input_check"></td>
      <td width="35%"> 
        <a href="<?php echo $list[$i][url]?>" target="_blank"><?php echo $list[$i][name]?></a> </td>
<!--      <td width="18%" align="center"><?php echo $OTHERLINK[$list[$i][fid]]?></td>
      <td width="9%" align="center"><?php echo $list[$i][ifshow]?></td>-->
      <td width="8%" align="center"> 
        <input type="text" name="listdb[<?php echo $list[$i][id] ?>]" size="7" value="<?php echo $list[$i]['list']?>">
      </td>
      <td width="12%" align="center"><?php echo $list[$i][yz]?></td>
      <td width="13%" align="center"><a href="yx_vpp_indexad.php?actions=modi&id=<?php echo $list[$i][id]?>">修改</a>&nbsp;&nbsp;<a href="yx_vpp_indexad.php?actions=del&id=<?php echo $list[$i][id]?>" onClick="return confirm('删除后不可恢复,你确实要删除吗?')">删除</a></td>
    </tr>
<?php
}
}
?>
<input type="hidden" name="actions" value="" />
</form>
</table>
<?php if ($c>0){?>
			<div class="height10"></div>
			<div class="do_div">
				<div class="l"><a href="javascript:CheckAll(document.form1,'all')">全选</a>&nbsp;<a href="javascript:CheckAll(document.form1,'')">反选</a><input type="hidden" name="jobs" value="0"></div>
				<div class="l2">
				选择操作：
				<a href="javascript:if (confirm('确定要删除选中的信息吗?')){ document.form1.actions.value='del';document.form1.submit();}">删除选中信息</a>
				<a href="javascript:document.form1.actions.value='list';document.form1.submit();">提交处理排序</a>
				</div>
			</div>
<?php }?>

<?php
  if ($c>$pagesize){
?>
			<div class="clear"></div>
			<div class="pagination">
			<?PHP
			echo $db->ThePage_mxsoft($s,$pageindex,$c,$pagesize)
			?>
			</div>
<?php
	}
?>
			<div class="clear"></div>
			<div class="height10"></div>
</div>
<script type="text/javascript" src="/mxsoft/js/jquerys-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){  
	$(".table_southidc tr").mouseover(function(){   
	$(this).addClass("list2");}).mouseout(function(){   
	$(this).removeClass("list2");}) //移除该行的class   
	$(".table_southidc tr:even").addClass("list1");   
});   
</script> 

<?php
}
?>
<div class="clear"></div>
<div class="height10"></div>
</div>
<?php require("../mx_foot.php");?>
<div class="clear"></div>
<div class="height10"></div>
<script language="javascript">
function check(){
//  if (document.form1.fid.value==""){
//    alert('请选择所属位置！');
//	document.form1.fid.focus();
//	return false;
//  }
  if (document.form1.postdb[name].value==""){
    alert('链接名称不能为空！');
	document.form1.postdb[name].focus();
	return false;
  }
  if (document.form1.postdb[url].value==""){
    alert('链接地址不能为空！');
	document.form1.postdb[url].focus();
	return false;
  }
  
}
</script>

</body>
</html>
